{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "emerging-translator",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np \n",
    "import pandas as pd \n",
    "import matplotlib as mpl \n",
    "import matplotlib.pyplot as plt \n",
    "%matplotlib inline \n",
    "from sklearn.datasets import load_iris\n",
    "#导入数据集 \n",
    "iris = load_iris()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "altered-respondent",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length (cm)</th>\n",
       "      <th>sepal width (cm)</th>\n",
       "      <th>petal length (cm)</th>\n",
       "      <th>petal width (cm)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)\n",
       "0                5.1               3.5                1.4               0.2\n",
       "1                4.9               3.0                1.4               0.2\n",
       "2                4.7               3.2                1.3               0.2\n",
       "3                4.6               3.1                1.5               0.2\n",
       "4                5.0               3.6                1.4               0.2"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "iris = pd.DataFrame(iris.data,columns=iris.feature_names)\n",
    "iris.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "about-functionality",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150, 4)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "iris.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "steady-smooth",
   "metadata": {},
   "source": [
    "### 手动实现"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "weekly-snapshot",
   "metadata": {},
   "outputs": [],
   "source": [
    "def distEclud(arrA, arrB): \n",
    "    '''计算两个数据集之间的欧式距离\n",
    "    注意：距离计算一定要注意量纲，此处鸢尾花不用考虑量纲'''\n",
    "    d = arrA - arrB \n",
    "    dist = np.sum(np.power(d, 2), axis=1) \n",
    "    return dist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "finnish-cabin",
   "metadata": {},
   "outputs": [],
   "source": [
    "def randCent(dataSet, k): \n",
    "    '''自动生成随机质心的函数'''\n",
    "    n = dataSet.shape[1] # n为列数，iris 一共5列\n",
    "    data_min = dataSet.iloc[:, :n-1].min() # 前4列，每一列最 小值 \n",
    "    data_max = dataSet.iloc[:, :n-1].max() # 前4列，每一列最 大值 \n",
    "    data_cent = np.random.uniform(data_min,data_max,(k, n-1))  # 均匀分布中抽样，形状为(k, n-1) \n",
    "    return data_cent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "understanding-recognition",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[6.86841093, 3.32724263, 4.33751213],\n",
       "       [7.86092662, 3.77945984, 5.00097333],\n",
       "       [6.52913294, 4.07008124, 5.64602289]])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 验证上述定义函数，在 iris 中随机生成三个质心\n",
    "iris_cent = randCent(iris, 3) \n",
    "iris_cent"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "acceptable-approach",
   "metadata": {},
   "source": [
    "### sklearn实现"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "continuous-drink",
   "metadata": {},
   "source": [
    "#### 创建数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "varying-heating",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1d77605e518>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD5CAYAAAAqaDI/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO2de5QU93Xnv7d7CujBjhoiHImWBmSvgtYEw1gTTMLmxMg2I+uBx3ohLYp94t1D7CS7C0eZDYp0DCjSms1EkfNWsOOz67Vsj2TQGAUlYAd2neUE2YNmMCGGBL0QPdoYC5pImhbq6bn7R3c11dW/Xz26qrqqp+/nHA4z1dVVt2tm7v397pOYGYIgCELn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PweZl7MzItRUVofTIIRcIOIbgTw2wDWMfNk3PI48AMA1xLRNUQ0C5VkjT0xy6RFKosVENEnAfwxgAUACgDGmbmfiB5ExW9tVVBrkxIc1Mldfe0BVHyqUwA2MXPifKtE9O8A/CEqO9W3Afw6Mx+JVyp3qn/oXwGwAsA7AH6LmQ/EK5V3iOhlAH3MnFjjZUJEpwDMBvB69dBhZv5sjCJpIaKbAHwRQBrAV5j5kZhF0iKGQBAEocMR15AgCEKHI4ZAEAShwxFDIAiC0OGIIRAEQehwxBAIgiB0OGIIBEEQOhwxBIIgCB3O/wf4D+t0r6qGHwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.datasets import make_blobs \n",
    "#自己创建数据集\n",
    "X, y = make_blobs(n_samples=500,n_features=2,centers=4,random_state=1) \n",
    "plt.scatter(X[:, 0], X[:, 1], marker='o')#点的形状 ,s=8 #点的大小"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "domestic-chance",
   "metadata": {},
   "source": [
    "#### 查看分布"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "technical-volleyball",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD5CAYAAAAqaDI/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO29e5Rc5XXg+9vV3Xq0TPNoREAW3RBamnslecxIDWMvu4HED2TZmOUQEXFZCXFIkPzIjGdN1iRAknFsYzLJzI3fRlyTWc5cjIJCsCFxhMGzBrUc21jS8OhWhGgkWpYlLNFgGqFnd+3546uv6tTpc6pOPU5VtWr/1upVdd771J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a06khbgZ7c97OBgyXObRU+Bvy5qp4EUNXDTZanEv4K+E+4373lUdXvqepUbvNHwOJmylOCK4ExVd2rqqeATbj/hy2JGYLauAH4314BtDBvBX4a2D6Q29eKfAr4SxH5KW5k3ZIjvhBLgSER+bGIPCkiVzRboCSIyIeBn6nqM82WpUp+B/inZgsRw2z6P9feaxaLyBPAhRGH7lTV75S5djnwX4D3pyFbiedWI7NE7GvaCLDUOwDvAf6Dqj4kIjcC9wHvbaR8UZSRuRM4F3gHcAXwoIj8srZAbnYZue+gwf9+k5Dk37iI3AlMAfc3UrYKaKn/c+Voa0OgqlUpGBFZDDwM/JaqvlhfqUpTpcwHgIsD24tposul1DuIyN8A/z63uRn4RkOEKkMZmT8G/H1O8T8lIllco7EjjZIvjji5ReRtwKXAMyIC7t/EThG5UlVfbqCIMyj3b1xEbgE+BLynFYxtDC31f64c5hqqkFyWwj8Ct6vqD5otT0IeAdaJyFwRuRRYAjzVZJniOAhcnfv+q8ALTZQlKd/GyYqILAXm0DrdJiNR1edU9QJVvURVL8EprpXNNgLlEJHVwB8CH1bVY82WpwQ/AZaIyKUiMgeXrPFIk2WKxSqLYxCRjwBfBhYCvwCeVtVrReSPcX7roIJ6fysECONkzh27E+dTnQI+paot6VsVkXcDX8TNVk8AH1fVHc2VqjS5/+h/DVwOnAL+QFX/Z3OlqgwReQkYVNWWNmAiMgbMBSZyu36kqhuaKFIsIrIG+ALQAfy1qt7VZJFiMUNgGIbR5phryDAMo80xQ2AYhtHmmCEwDMNoc8wQGIZhtDlmCAzDMNocMwSGYRhtjhkCwzCMNuf/AOsuSkzG/imnAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#查看分布 \n",
    "color = [\"red\",\"pink\",\"orange\",\"gray\"] \n",
    "for i in range(4): \n",
    "    plt.scatter(X[y==i, 0],\n",
    "                X[y==i, 1] ,\n",
    "                marker='o', #点的形状 \n",
    "                s=8 , #点的大小\n",
    "                c=color[i] ) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "realistic-fever",
   "metadata": {},
   "source": [
    "KMeans 因为并不需要建立模型或者预测结果，因此我们只需要 fit 就能够得到聚类结果了    \n",
    "KMeans 也有接口 predict 和 fit_predict:    \n",
    "predict 表示学习数据 X 并对 X 的类进行预测（对分类器.fit()之后，再预测)    \n",
    "fit_predict 不需要分类器.fit()之后都可以预测    \n",
    "对于全数据而言，分类器.fit().predict 的结果= 分类器.fit_predict(X)=cluster.labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "australian-tennessee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 2, 1, 2, 1, 2, 2, 2, 2, 0, 0, 2, 1, 2, 0, 2, 0, 1, 2, 2, 2,\n",
       "       2, 1, 2, 2, 1, 1, 2, 2, 0, 1, 2, 0, 2, 0, 2, 2, 0, 2, 2, 2, 1, 2,\n",
       "       2, 0, 2, 2, 1, 1, 1, 2, 2, 2, 0, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 2,\n",
       "       0, 2, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1,\n",
       "       2, 2, 1, 0, 2, 2, 1, 0, 0, 2, 0, 1, 1, 0, 1, 2, 1, 2, 2, 1, 1, 2,\n",
       "       2, 0, 1, 2, 1, 2, 1, 2, 1, 2, 2, 0, 0, 2, 2, 2, 1, 0, 0, 2, 1, 2,\n",
       "       2, 2, 2, 0, 1, 2, 1, 1, 2, 0, 2, 1, 1, 1, 2, 2, 0, 0, 2, 2, 1, 0,\n",
       "       1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 2, 1, 0, 2, 2, 0, 1, 2,\n",
       "       2, 2, 2, 0, 2, 2, 1, 0, 0, 2, 2, 0, 0, 2, 1, 1, 0, 0, 2, 1, 2, 0,\n",
       "       0, 1, 0, 2, 1, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 1, 2, 1,\n",
       "       2, 0, 2, 2, 2, 2, 2, 1, 2, 1, 0, 2, 0, 2, 1, 1, 2, 0, 1, 0, 2, 2,\n",
       "       0, 0, 0, 0, 2, 2, 0, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2,\n",
       "       1, 2, 0, 0, 2, 2, 2, 2, 1, 1, 2, 1, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1,\n",
       "       1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 0, 0, 2, 2, 2, 0, 2, 0, 0, 2, 0,\n",
       "       0, 2, 1, 0, 2, 2, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 2, 1, 2, 2, 0,\n",
       "       0, 1, 2, 0, 2, 1, 1, 2, 2, 2, 0, 2, 1, 1, 2, 1, 1, 1, 1, 0, 0, 2,\n",
       "       1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 0, 1, 0, 0, 0, 0, 0,\n",
       "       0, 2, 0, 1, 0, 1, 1, 2, 1, 2, 2, 2, 0, 1, 2, 1, 2, 0, 2, 2, 0, 2,\n",
       "       2, 1, 1, 0, 2, 2, 1, 2, 2, 0, 0, 2, 0, 2, 2, 0, 2, 0, 2, 1, 0, 1,\n",
       "       2, 2, 1, 2, 2, 1, 0, 2, 1, 1, 2, 2, 2, 2, 0, 1, 0, 2, 1, 0, 0, 0,\n",
       "       2, 1, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 1, 2,\n",
       "       1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 0, 2, 1, 2, 0, 1, 0, 1, 0, 2, 1, 1,\n",
       "       0, 2, 2, 0, 2, 2, 2, 0, 2, 1, 2, 2, 0, 0, 0, 2])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.cluster import KMeans \n",
    "n_clusters = 3 \n",
    "cluster = KMeans(n_clusters=n_clusters, random_state=0).fit(X) \n",
    "y_pred = cluster.labels_ \n",
    "y_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "included-blair",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "500"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fit_pre = KMeans(n_clusters=3, random_state=0).fit_predict(X) \n",
    "(cluster.predict(X)==fit_pre).sum() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "yellow-trance",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "500"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(fit_pre== cluster.labels_).sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "rocky-studio",
   "metadata": {},
   "source": [
    "#### 重要属性"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "surprising-tulsa",
   "metadata": {},
   "source": [
    "查看质心"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "effective-harvard",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7.09306648, -8.10994454],\n",
       "       [-1.54234022,  4.43517599],\n",
       "       [-8.0862351 , -3.5179868 ]])"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#查看质心\n",
    "centroid = cluster.cluster_centers_ \n",
    "centroid "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "finished-import",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 2)"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "centroid.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "exceptional-convergence",
   "metadata": {},
   "source": [
    "查看总距离平方和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "characteristic-inventory",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1903.4503741659223"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inertia = cluster.inertia_ \n",
    "inertia"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "threatened-consequence",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "908.3855684760613"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_clusters = 4 \n",
    "cluster_ = KMeans(n_clusters=n_clusters, random_state=0).fit(X) \n",
    "inertia_ = cluster_.inertia_ \n",
    "inertia_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "pacific-template",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "811.0952123653019"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_clusters = 5 \n",
    "cluster_ = KMeans(n_clusters=n_clusters, random_state=0).fit(X) \n",
    "inertia_ = cluster_.inertia_ \n",
    "inertia_"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aquatic-strap",
   "metadata": {},
   "source": [
    "分的簇越多，距离平方和越小，越好。但是太多分的就没有意义了"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "vietnamese-registrar",
   "metadata": {},
   "source": [
    "#### 轮廓系数--聚类算法的模型评估指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "distributed-removal",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-6.92324165e+00, -1.06695320e+01],\n",
       "       [-8.63062033e+00, -7.13940564e+00],\n",
       "       [-9.63048069e+00, -2.72044935e+00],\n",
       "       [-2.30647659e+00,  5.30797676e+00],\n",
       "       [-7.57005366e+00, -3.01446491e+00],\n",
       "       [-1.00051011e+00,  2.77905153e+00],\n",
       "       [-4.81826839e+00, -2.77214822e+00],\n",
       "       [-5.33964799e+00, -1.27625764e+00],\n",
       "       [-7.94308840e+00, -3.89993901e+00],\n",
       "       [-5.54924525e+00, -3.41298968e+00],\n",
       "       [-5.14508990e+00, -9.54492198e+00],\n",
       "       [-7.09669936e+00, -8.04074036e+00],\n",
       "       [-5.82641512e+00, -1.96346196e+00],\n",
       "       [-1.83198811e+00,  3.52863145e+00],\n",
       "       [-7.34267235e+00, -3.16546482e+00],\n",
       "       [-7.34072825e+00, -6.92427252e+00],\n",
       "       [-7.94653906e+00, -3.36768655e+00],\n",
       "       [-8.24598536e+00, -8.61315821e+00],\n",
       "       [-1.98197711e+00,  4.02243551e+00],\n",
       "       [-4.35098035e+00, -3.69476678e+00],\n",
       "       [-1.04768696e+01, -3.60318139e+00],\n",
       "       [-1.10195984e+01, -3.15882031e+00],\n",
       "       [-5.17255904e+00, -4.31835971e+00],\n",
       "       [-2.40671820e+00,  6.09894447e+00],\n",
       "       [-6.72149498e+00, -2.88440806e+00],\n",
       "       [-6.58935963e+00, -4.43379548e+00],\n",
       "       [-1.46126019e+00,  4.52549851e+00],\n",
       "       [-9.19003455e-01,  3.45278927e+00],\n",
       "       [-1.04093517e+01, -2.67482046e+00],\n",
       "       [-6.36722809e+00, -3.32666072e+00],\n",
       "       [-6.72766125e+00, -7.14516267e+00],\n",
       "       [-2.27956075e+00,  5.10452190e+00],\n",
       "       [-5.84887560e+00, -3.03970506e+00],\n",
       "       [-6.07993051e+00, -7.08197568e+00],\n",
       "       [-5.26682929e+00, -2.69645055e+00],\n",
       "       [-6.05367512e+00, -9.62979077e+00],\n",
       "       [-1.00822205e+01, -4.25071043e+00],\n",
       "       [-1.18708735e+01, -3.03273343e+00],\n",
       "       [-5.37107307e+00, -7.95635833e+00],\n",
       "       [-9.37590900e+00, -4.55315308e+00],\n",
       "       [-6.63401987e+00, -2.58340356e+00],\n",
       "       [-9.54609655e+00, -2.84917422e+00],\n",
       "       [-1.69825542e+00,  2.79071751e+00],\n",
       "       [-5.60217602e+00, -6.59908490e-01],\n",
       "       [-6.03429022e+00, -4.08821196e+00],\n",
       "       [-6.37230784e+00, -8.63190046e+00],\n",
       "       [-1.02264783e+01, -2.33998717e+00],\n",
       "       [-5.95678148e+00, -3.97905701e+00],\n",
       "       [-1.42706535e+00,  5.08904128e+00],\n",
       "       [-6.20735304e-01,  6.59346952e+00],\n",
       "       [-3.28102793e-01,  4.11918201e+00],\n",
       "       [-1.06230545e+01, -4.54719161e+00],\n",
       "       [-9.12674270e+00, -4.46180568e+00],\n",
       "       [-5.24134497e+00, -3.23505873e+00],\n",
       "       [-7.19967531e+00, -7.10400981e+00],\n",
       "       [-1.01136977e+01, -4.12880752e+00],\n",
       "       [-1.03416132e+01, -4.95351774e+00],\n",
       "       [-1.25041532e+01, -6.06751247e+00],\n",
       "       [-9.32331640e+00, -4.67574045e+00],\n",
       "       [-7.32033002e+00, -2.73350095e+00],\n",
       "       [-2.20533407e+00,  4.20765201e+00],\n",
       "       [-5.27930518e-01,  5.92630669e+00],\n",
       "       [-8.87430034e+00, -3.64808151e+00],\n",
       "       [-6.66948545e+00, -4.26059884e+00],\n",
       "       [-1.37397258e+00,  5.29163103e+00],\n",
       "       [-6.60085708e+00, -3.11969688e+00],\n",
       "       [-7.99175412e+00, -8.33564851e+00],\n",
       "       [-6.22447869e+00, -2.43846224e+00],\n",
       "       [-1.11054250e+01, -3.97106687e+00],\n",
       "       [-8.95762335e+00, -4.87178859e+00],\n",
       "       [-6.65461644e+00, -7.29335713e+00],\n",
       "       [-1.09531378e+01, -3.36743812e+00],\n",
       "       [-5.11351008e+00, -2.01881992e+00],\n",
       "       [-7.24251438e+00, -9.66368448e+00],\n",
       "       [-5.34929456e+00, -3.54577332e+00],\n",
       "       [-6.29261332e+00, -3.68892426e+00],\n",
       "       [-7.35387953e+00, -8.54504434e+00],\n",
       "       [-5.78423473e+00, -4.48406848e+00],\n",
       "       [-5.66256325e+00, -2.34390092e+00],\n",
       "       [-8.60893311e+00, -4.61469279e+00],\n",
       "       [-2.52019906e-01,  4.53559145e+00],\n",
       "       [-1.92744799e+00,  4.93684534e+00],\n",
       "       [-9.41306589e+00, -3.62907430e+00],\n",
       "       [-8.48608233e-01,  5.45093196e+00],\n",
       "       [-8.66753040e-01,  3.78295914e+00],\n",
       "       [-1.01842915e+01, -4.01017303e+00],\n",
       "       [-7.93192918e+00, -5.42450547e+00],\n",
       "       [-2.75447175e+00,  4.57587230e+00],\n",
       "       [-1.17171070e+01, -3.89622755e+00],\n",
       "       [-8.85081213e+00, -4.00305113e+00],\n",
       "       [-1.34392496e+00,  2.38428865e+00],\n",
       "       [-8.16203654e+00, -7.31459336e+00],\n",
       "       [-9.18886814e+00, -2.16359386e+00],\n",
       "       [-7.13229260e+00, -4.02296730e+00],\n",
       "       [-4.26103071e-02,  4.90923075e+00],\n",
       "       [-7.24449448e+00, -7.65150300e+00],\n",
       "       [-8.13784646e+00, -7.65806949e+00],\n",
       "       [-6.73451345e+00, -1.38330194e+00],\n",
       "       [-8.96369424e+00, -9.27033880e+00],\n",
       "       [ 8.68765801e-01,  4.15785509e+00],\n",
       "       [-5.45176929e-01,  3.81996593e+00],\n",
       "       [-8.01694428e+00, -8.67137366e+00],\n",
       "       [-3.33375571e+00,  5.23151969e+00],\n",
       "       [-1.14385885e+01, -2.72109548e+00],\n",
       "       [-2.52087627e+00,  5.08120139e+00],\n",
       "       [-6.84394443e+00, -4.15058222e+00],\n",
       "       [-5.87619738e+00, -3.28078916e+00],\n",
       "       [-1.21819546e+00,  4.30633464e+00],\n",
       "       [-2.00341358e+00,  4.45008673e+00],\n",
       "       [-1.01077040e+01, -3.94479960e+00],\n",
       "       [-7.03045854e+00, -1.23734756e+00],\n",
       "       [-6.95685137e+00, -8.12381049e+00],\n",
       "       [-2.33022219e+00,  4.78405366e+00],\n",
       "       [-9.98435983e+00, -4.64804214e+00],\n",
       "       [-2.33080604e+00,  4.39382527e+00],\n",
       "       [-1.07796242e+01, -4.39085753e+00],\n",
       "       [-2.03484486e+00,  3.76775946e+00],\n",
       "       [-7.16744245e+00, -3.24998378e+00],\n",
       "       [-4.99221336e-01,  4.77598259e+00],\n",
       "       [-5.76681144e+00, -3.41281779e+00],\n",
       "       [-1.06990569e+01, -4.49057157e+00],\n",
       "       [-7.28729621e+00, -6.68306776e+00],\n",
       "       [-8.17831829e+00, -8.22063813e+00],\n",
       "       [-9.14443128e+00, -4.36637786e+00],\n",
       "       [-7.22323543e+00, -3.51226376e+00],\n",
       "       [-9.71296439e+00, -3.69088110e+00],\n",
       "       [-3.19091528e-02,  4.74450157e+00],\n",
       "       [-7.10406044e+00, -8.38198228e+00],\n",
       "       [-7.52482501e+00, -7.50887444e+00],\n",
       "       [-6.31161343e+00, -2.97641697e+00],\n",
       "       [-5.38142198e-01,  4.81539041e+00],\n",
       "       [-9.58041050e+00, -3.16857790e+00],\n",
       "       [-9.53106924e+00, -2.91966168e+00],\n",
       "       [-1.07650223e+01, -3.27877784e+00],\n",
       "       [-9.54658956e+00, -4.64826945e+00],\n",
       "       [-7.39393373e+00, -6.80612264e+00],\n",
       "       [-2.99151157e+00,  2.64580131e+00],\n",
       "       [-5.67558254e+00, -4.55902255e+00],\n",
       "       [-3.51754177e+00,  5.64265390e+00],\n",
       "       [-9.98539618e-01,  6.19864808e+00],\n",
       "       [-5.96497901e+00, -2.03746469e+00],\n",
       "       [-8.85279507e+00, -7.79138079e+00],\n",
       "       [-4.64310426e+00, -2.22789422e+00],\n",
       "       [-1.35938959e+00,  4.05424002e+00],\n",
       "       [-5.25790464e-01,  3.30659860e+00],\n",
       "       [-1.15637509e+00,  5.69971575e+00],\n",
       "       [-6.42530010e+00, -2.17328619e+00],\n",
       "       [-5.70183305e+00, -2.63083838e+00],\n",
       "       [-6.04632971e+00, -6.92266990e+00],\n",
       "       [-8.14559288e+00, -7.42775410e+00],\n",
       "       [-9.15685095e+00, -4.05623576e+00],\n",
       "       [-9.16170778e+00, -2.40998944e+00],\n",
       "       [-1.46864442e+00,  6.50674501e+00],\n",
       "       [-6.74672798e+00, -8.17245974e+00],\n",
       "       [-1.98605940e+00,  3.06381408e+00],\n",
       "       [-1.03289957e+01, -3.56680940e+00],\n",
       "       [-9.34313235e+00, -4.00453699e+00],\n",
       "       [-9.55954616e+00, -2.83102023e+00],\n",
       "       [-1.01659113e+01, -4.12752889e+00],\n",
       "       [-9.84144865e+00, -4.14356957e+00],\n",
       "       [-1.02768102e+01, -2.33049946e+00],\n",
       "       [-1.01030572e+01, -3.32315288e+00],\n",
       "       [-9.90228742e+00, -3.03189848e+00],\n",
       "       [-9.72121320e+00, -4.68662015e+00],\n",
       "       [-1.85139546e+00,  3.51886090e+00],\n",
       "       [-6.69321189e+00, -6.30021862e+00],\n",
       "       [-6.53371839e+00, -8.14922726e+00],\n",
       "       [-8.46369500e+00, -8.07146029e+00],\n",
       "       [-5.75004528e+00, -3.56590967e+00],\n",
       "       [-1.17104176e+00,  4.33091816e+00],\n",
       "       [-8.52628579e+00, -8.66957601e+00],\n",
       "       [-9.23890684e+00, -3.06843973e+00],\n",
       "       [-6.12803051e+00, -2.51698058e+00],\n",
       "       [-8.10406451e+00, -7.42020487e+00],\n",
       "       [-1.61589091e+00,  4.18017563e+00],\n",
       "       [-8.98758533e+00, -3.03333061e+00],\n",
       "       [-1.19410359e+01, -3.60085418e+00],\n",
       "       [-1.04399418e+01, -3.62982119e+00],\n",
       "       [-1.14242679e+01, -2.18538860e+00],\n",
       "       [-9.00992914e+00, -9.06865247e+00],\n",
       "       [-6.47435649e+00, -3.74338863e+00],\n",
       "       [-9.63138049e+00, -4.99793793e+00],\n",
       "       [ 5.26015501e-01,  3.00999353e+00],\n",
       "       [-9.76324393e+00, -9.36656623e+00],\n",
       "       [-6.27965526e+00, -8.81809587e+00],\n",
       "       [-9.46883276e+00, -6.19043506e+00],\n",
       "       [-5.77336618e+00, -3.56739953e+00],\n",
       "       [-6.69242533e+00, -8.30171791e+00],\n",
       "       [-7.44439970e+00, -9.16803180e+00],\n",
       "       [-7.11478469e+00, -5.38699134e+00],\n",
       "       [-3.85803976e-01,  6.37359162e+00],\n",
       "       [-2.00454712e+00,  4.17565013e+00],\n",
       "       [-5.75517628e+00, -9.30821074e+00],\n",
       "       [-9.14168421e+00, -7.20572694e+00],\n",
       "       [-5.92092535e+00, -3.27574048e+00],\n",
       "       [-2.35122066e+00,  4.00973634e+00],\n",
       "       [-5.91907851e+00, -2.23919861e+00],\n",
       "       [-5.62200526e+00, -8.69290967e+00],\n",
       "       [-7.54246304e+00, -8.12722811e+00],\n",
       "       [-2.41395785e+00,  5.65935802e+00],\n",
       "       [-6.37151596e+00, -8.91129543e+00],\n",
       "       [-1.21401792e+01, -4.78351741e+00],\n",
       "       [-4.45264491e+00,  6.34401868e+00],\n",
       "       [-5.59698820e+00, -4.19535853e+00],\n",
       "       [-6.07503622e+00, -2.15606405e+00],\n",
       "       [-7.24828238e+00, -7.05222790e+00],\n",
       "       [-4.77891101e+00, -2.41333165e+00],\n",
       "       [-1.24112155e+01, -5.73091492e+00],\n",
       "       [-6.75264349e+00, -8.34654975e+00],\n",
       "       [-5.05492139e+00, -4.22257749e+00],\n",
       "       [-1.03825448e+01, -2.49524031e+00],\n",
       "       [-7.22570502e+00, -3.79313579e+00],\n",
       "       [-1.19498178e+01, -5.35567769e+00],\n",
       "       [-7.62867092e+00, -8.06354170e+00],\n",
       "       [-4.61767113e+00, -1.67111145e+00],\n",
       "       [-5.12219664e+00, -3.31302123e+00],\n",
       "       [-6.29225072e+00, -2.35738294e+00],\n",
       "       [ 2.42271161e-04,  5.14853403e+00],\n",
       "       [-8.79988166e+00, -2.24875438e+00],\n",
       "       [-2.77687025e+00,  4.64090557e+00],\n",
       "       [-6.39694979e+00, -3.76963703e+00],\n",
       "       [-6.92263081e+00, -7.63972262e+00],\n",
       "       [-1.15768688e+01, -4.78197653e+00],\n",
       "       [-5.66824737e+00, -3.82607509e+00],\n",
       "       [-1.11578826e+01, -2.60324173e+00],\n",
       "       [-1.04730854e+01, -3.47573837e+00],\n",
       "       [-9.98118494e+00, -3.77616083e+00],\n",
       "       [-1.04102078e+00,  3.96331794e+00],\n",
       "       [-9.32856015e+00, -2.60893309e+00],\n",
       "       [-1.13898357e+00,  3.26214848e+00],\n",
       "       [-6.17905638e+00, -7.96336646e+00],\n",
       "       [-1.02356544e+01, -2.79806066e+00],\n",
       "       [-5.77133256e+00, -8.59222577e+00],\n",
       "       [-9.14500844e+00, -3.91798845e+00],\n",
       "       [-1.61734616e+00,  4.98930508e+00],\n",
       "       [-2.77867530e+00,  6.36256877e+00],\n",
       "       [-9.54642849e+00, -5.63740853e+00],\n",
       "       [-6.91486590e+00, -7.68969378e+00],\n",
       "       [-1.84612968e+00,  4.30474400e+00],\n",
       "       [-5.52834586e+00, -8.15360311e+00],\n",
       "       [-6.00915337e+00, -3.34925152e+00],\n",
       "       [-8.54628324e+00, -4.57138540e+00],\n",
       "       [-7.31655639e+00, -7.77051293e+00],\n",
       "       [-7.20423399e+00, -8.88176559e+00],\n",
       "       [-7.55600732e+00, -8.01885499e+00],\n",
       "       [-5.67856792e+00, -7.60509852e+00],\n",
       "       [-5.21446826e+00, -4.79995312e+00],\n",
       "       [-9.37662980e+00, -2.99722684e+00],\n",
       "       [-5.31844709e+00, -8.92829839e+00],\n",
       "       [-1.08278844e+01, -4.83392615e+00],\n",
       "       [-6.06569910e+00, -1.53376946e+00],\n",
       "       [-2.34673261e+00,  3.56128423e+00],\n",
       "       [-1.25606826e+00,  5.00006839e+00],\n",
       "       [-5.83979745e+00, -2.17836186e+00],\n",
       "       [-6.87088211e+00, -2.22716236e+00],\n",
       "       [-1.79600465e+00,  4.28743568e+00],\n",
       "       [-9.37972697e+00, -4.13752487e+00],\n",
       "       [-7.23605937e+00, -4.54710992e+00],\n",
       "       [-1.02794488e+01, -1.89699302e+00],\n",
       "       [-1.41689046e+00,  4.60832005e+00],\n",
       "       [-5.78045412e+00, -4.58297922e+00],\n",
       "       [ 8.52518583e-02,  3.64528297e+00],\n",
       "       [-9.20268641e+00, -4.32778687e+00],\n",
       "       [-9.56818636e+00, -4.56034695e+00],\n",
       "       [-1.16434858e+00,  4.23178671e+00],\n",
       "       [-6.16345851e+00, -3.10830802e+00],\n",
       "       [-6.32152564e+00, -9.66280079e+00],\n",
       "       [-7.52099974e+00, -9.13311836e+00],\n",
       "       [-9.22029330e+00, -4.07211972e+00],\n",
       "       [-1.08491682e+01, -2.95246712e+00],\n",
       "       [-9.86366431e+00, -2.75129369e+00],\n",
       "       [-6.79715224e+00, -3.45804136e+00],\n",
       "       [-9.79490066e-01,  4.08668827e+00],\n",
       "       [-2.06043810e+00,  5.23049549e+00],\n",
       "       [-5.66839183e+00, -7.95067847e-01],\n",
       "       [-7.57969185e-01,  4.90898421e+00],\n",
       "       [-1.04205695e+01, -3.86688414e+00],\n",
       "       [-7.12425009e+00, -6.70423870e+00],\n",
       "       [-1.37889483e+00,  4.33337717e+00],\n",
       "       [-6.61466444e+00, -7.52579102e+00],\n",
       "       [-1.34052081e+00,  4.15711949e+00],\n",
       "       [-6.21160000e+00, -8.29293984e+00],\n",
       "       [-7.56885613e+00, -8.13527221e+00],\n",
       "       [-1.77000693e+00,  3.78912781e+00],\n",
       "       [-7.36585834e+00, -7.34577219e+00],\n",
       "       [-1.49952284e+00,  5.28265879e+00],\n",
       "       [-2.85882794e+00,  5.26983519e+00],\n",
       "       [-7.73884935e+00, -3.24327665e+00],\n",
       "       [-1.08201797e+01, -3.23163726e+00],\n",
       "       [-8.53682012e+00, -3.36087575e+00],\n",
       "       [-1.20349137e+01, -5.89593773e+00],\n",
       "       [-5.26910909e+00, -2.73521824e+00],\n",
       "       [-6.71299604e+00, -2.90324984e+00],\n",
       "       [-8.36118634e+00, -2.72698382e+00],\n",
       "       [-5.48941428e+00, -6.94662021e+00],\n",
       "       [ 5.31139823e-01,  2.51012895e+00],\n",
       "       [-5.64126775e+00, -7.24922893e+00],\n",
       "       [-9.48263889e+00, -6.73588302e+00],\n",
       "       [-7.53103704e+00, -6.76823676e+00],\n",
       "       [-6.31078595e+00, -2.05174648e+00],\n",
       "       [-8.70233178e+00, -4.19462540e+00],\n",
       "       [-6.11013071e+00, -2.31061128e+00],\n",
       "       [-5.83972633e+00, -9.20677418e+00],\n",
       "       [-1.17536381e+01, -3.23855895e+00],\n",
       "       [-9.29199482e+00, -9.85256171e+00],\n",
       "       [-7.85568214e+00, -6.92950589e+00],\n",
       "       [-1.01967107e+01, -2.08687717e+00],\n",
       "       [-7.96356538e+00, -7.83357116e+00],\n",
       "       [-6.77680402e+00, -6.65511992e+00],\n",
       "       [-1.08749940e+01, -4.82113577e+00],\n",
       "       [-1.84048021e+00,  3.80256924e+00],\n",
       "       [-7.98067403e+00, -8.56048015e+00],\n",
       "       [-6.32066246e+00, -3.30751892e+00],\n",
       "       [-6.17979966e+00, -3.00803447e+00],\n",
       "       [-2.17665436e+00,  3.40946304e+00],\n",
       "       [-6.73224718e-01,  4.62002377e+00],\n",
       "       [-8.93892171e+00, -3.51521408e+00],\n",
       "       [-7.48937497e+00, -8.88475909e+00],\n",
       "       [-2.89641328e+00,  5.28232880e+00],\n",
       "       [-8.13399258e-01,  3.54697393e+00],\n",
       "       [-5.77752667e+00, -2.85145276e+00],\n",
       "       [-6.24883850e+00, -8.76563508e+00],\n",
       "       [-3.10367371e+00,  3.90202401e+00],\n",
       "       [-1.05724063e+00,  4.82677207e+00],\n",
       "       [-5.73215048e+00, -5.04695454e+00],\n",
       "       [-9.93696231e+00, -3.74222379e+00],\n",
       "       [-3.03267723e+00,  4.72164926e+00],\n",
       "       [-1.07035530e+01, -2.76066248e+00],\n",
       "       [-5.68475631e+00, -3.76816924e+00],\n",
       "       [-8.62182374e+00, -8.76567023e+00],\n",
       "       [-6.67177294e+00, -9.97714796e+00],\n",
       "       [-1.92577841e+00,  4.43910442e+00],\n",
       "       [-8.16299488e+00, -3.38896569e+00],\n",
       "       [-3.74380343e+00, -8.75345344e+00],\n",
       "       [-5.66601211e+00, -4.97019633e+00],\n",
       "       [-2.88961804e+00,  4.95702736e+00],\n",
       "       [-2.35995841e+00,  4.20309542e+00],\n",
       "       [-6.80491557e+00, -3.49602548e+00],\n",
       "       [-7.10480676e+00, -4.10830531e+00],\n",
       "       [-6.96685539e+00, -3.12876392e+00],\n",
       "       [-6.31354495e+00, -8.01283267e+00],\n",
       "       [-4.47120679e+00, -3.54131043e+00],\n",
       "       [-1.53940095e+00,  5.02369298e+00],\n",
       "       [-1.60875215e+00,  3.76949422e+00],\n",
       "       [-1.01927698e+01, -3.14795512e+00],\n",
       "       [-2.80207810e+00,  4.05714715e+00],\n",
       "       [ 2.45098802e-01,  5.51754657e+00],\n",
       "       [-3.31028117e+00,  3.51593428e+00],\n",
       "       [-2.84187803e+00,  3.74073535e+00],\n",
       "       [-5.75867612e+00, -8.75783107e+00],\n",
       "       [-5.99591056e+00, -8.11285667e+00],\n",
       "       [-4.98360687e+00, -3.20522961e+00],\n",
       "       [-1.86845414e+00,  4.99311306e+00],\n",
       "       [-9.71503679e+00, -4.77944598e+00],\n",
       "       [-6.47373322e+00, -2.78682541e+00],\n",
       "       [-6.99263028e+00, -7.14344077e+00],\n",
       "       [-1.53773863e+00,  5.53597378e+00],\n",
       "       [-1.04464505e+01, -4.62579659e+00],\n",
       "       [-1.09679881e+00,  4.64722696e+00],\n",
       "       [-7.25256877e+00, -2.91682833e+00],\n",
       "       [-1.97451969e-01,  2.34634916e+00],\n",
       "       [-1.00670412e+01, -4.06174061e+00],\n",
       "       [-6.13468589e+00, -4.50793424e+00],\n",
       "       [-1.03725172e+01, -4.70331816e+00],\n",
       "       [-1.88188805e+00,  4.20573180e+00],\n",
       "       [-7.15498484e+00, -3.10778598e+00],\n",
       "       [-6.14254799e+00, -3.65202206e+00],\n",
       "       [-7.42749427e+00, -9.63838456e+00],\n",
       "       [-1.13009458e+00,  4.54419108e+00],\n",
       "       [-6.28485505e+00, -8.78266971e+00],\n",
       "       [-7.33325349e+00, -8.28490373e+00],\n",
       "       [-6.40320111e+00, -7.16687592e+00],\n",
       "       [-7.22187586e+00, -9.48843083e+00],\n",
       "       [-6.09834293e+00, -7.44017905e+00],\n",
       "       [-7.20807793e+00, -7.12024433e+00],\n",
       "       [-9.68744022e+00, -6.04759636e+00],\n",
       "       [-7.87372938e+00, -7.59578865e+00],\n",
       "       [-1.14663009e+00,  4.10839703e+00],\n",
       "       [-5.90344220e+00, -8.18075749e+00],\n",
       "       [-2.76017908e+00,  5.55121358e+00],\n",
       "       [-1.23606555e+00,  4.48382994e+00],\n",
       "       [-9.97584967e+00, -4.42202236e+00],\n",
       "       [-2.10668847e+00,  5.63099757e+00],\n",
       "       [-4.73558876e+00, -4.23748969e+00],\n",
       "       [-1.07233096e+01, -4.82111722e+00],\n",
       "       [-8.26074369e+00, -5.64724782e+00],\n",
       "       [-6.88384344e+00, -7.04605265e+00],\n",
       "       [-2.15777347e+00,  4.09550489e+00],\n",
       "       [-7.85988444e+00, -4.73888254e+00],\n",
       "       [-4.60642026e-01,  4.59164629e+00],\n",
       "       [-5.05685487e+00, -5.02946642e+00],\n",
       "       [-7.66055006e+00, -8.46234942e+00],\n",
       "       [-8.41923982e+00, -3.45834788e+00],\n",
       "       [-1.09947323e+01, -4.06014253e+00],\n",
       "       [-6.71376529e+00, -8.22199857e+00],\n",
       "       [-1.07972600e+01, -4.24494314e+00],\n",
       "       [-8.23746328e+00, -4.01400104e+00],\n",
       "       [-2.93211866e+00,  4.72003759e+00],\n",
       "       [-1.66145139e+00,  3.00986944e+00],\n",
       "       [-7.65734347e+00, -1.04581360e+01],\n",
       "       [-9.98054778e+00, -4.38249083e+00],\n",
       "       [-5.51940374e+00, -2.38780334e+00],\n",
       "       [-1.96967668e+00,  1.97165210e+00],\n",
       "       [-3.88464981e+00, -2.84336261e+00],\n",
       "       [-5.82969906e+00, -2.99067321e+00],\n",
       "       [-6.66700176e+00, -9.14923899e+00],\n",
       "       [-6.62889599e+00, -8.84071550e+00],\n",
       "       [-6.48944961e+00, -2.06753733e+00],\n",
       "       [-7.17134231e+00, -1.09442245e+01],\n",
       "       [-1.13042466e+01, -3.87696807e+00],\n",
       "       [-9.53654840e+00, -5.12933122e+00],\n",
       "       [-6.09866132e+00, -7.42731125e+00],\n",
       "       [-8.78925618e+00, -2.83764674e+00],\n",
       "       [-7.32386504e+00, -7.96393491e+00],\n",
       "       [-1.00330804e+01, -1.84274349e+00],\n",
       "       [-1.03619773e+00,  3.97153319e+00],\n",
       "       [-6.42829877e+00, -6.74397472e+00],\n",
       "       [-2.87930430e+00,  6.85585852e+00],\n",
       "       [-1.05299465e+01, -2.83521515e+00],\n",
       "       [-6.11423078e+00, -3.20893543e+00],\n",
       "       [-1.78245013e+00,  3.47072043e+00],\n",
       "       [-8.95271809e+00, -3.34483385e+00],\n",
       "       [-5.16617901e+00, -3.79170586e+00],\n",
       "       [-1.64215050e+00,  3.28447114e+00],\n",
       "       [-8.33534296e+00, -7.87023257e+00],\n",
       "       [-6.31107706e+00, -3.92118081e+00],\n",
       "       [-1.78002448e+00,  3.17336913e+00],\n",
       "       [-1.68417686e+00,  3.63132825e+00],\n",
       "       [-1.05552072e+01, -3.01417980e+00],\n",
       "       [-5.34354009e+00, -2.13897664e+00],\n",
       "       [-1.15365057e+01, -4.40124373e+00],\n",
       "       [-4.89503758e+00, -2.48633456e+00],\n",
       "       [-5.44396990e+00, -8.95941292e+00],\n",
       "       [-1.58173878e+00,  5.02487013e+00],\n",
       "       [-7.02993859e+00, -6.69931052e+00],\n",
       "       [-6.17074238e+00, -2.56078204e+00],\n",
       "       [-2.22186534e+00,  6.36136794e+00],\n",
       "       [-7.57385446e+00, -8.31971406e+00],\n",
       "       [-7.65822594e+00, -7.64292051e+00],\n",
       "       [-6.89501293e+00, -9.31723608e+00],\n",
       "       [-1.11141825e+01, -3.87242145e+00],\n",
       "       [-7.94152277e-01,  2.10495117e+00],\n",
       "       [-6.42803193e+00, -5.52129397e+00],\n",
       "       [-5.89780702e+00, -8.19289680e+00],\n",
       "       [-6.59169697e+00, -2.44779959e+00],\n",
       "       [-6.45785776e+00, -3.30981436e+00],\n",
       "       [-1.07755713e+01, -2.83750744e+00],\n",
       "       [-1.02341495e+01, -3.22553505e+00],\n",
       "       [-6.26681839e+00, -8.25516014e+00],\n",
       "       [-5.20580980e+00, -3.29853839e+00],\n",
       "       [-5.46045264e+00, -2.30831553e+00],\n",
       "       [-7.04259952e+00, -3.45332351e+00],\n",
       "       [-6.09962804e+00, -3.14226915e+00],\n",
       "       [-5.66006950e+00, -3.43776965e+00],\n",
       "       [-7.08097398e+00, -3.03972377e+00],\n",
       "       [-8.41264712e+00, -6.68248825e+00],\n",
       "       [-7.36513410e+00, -1.38859731e+00],\n",
       "       [-1.04166504e+01, -4.43253346e+00],\n",
       "       [-6.41623854e+00, -8.04588481e+00],\n",
       "       [-5.88919348e+00, -2.37049472e+00],\n",
       "       [-1.42946517e+00,  5.16850105e+00],\n",
       "       [-6.56118069e+00, -3.95967311e+00],\n",
       "       [-1.47299851e+00,  4.81654152e+00],\n",
       "       [-5.88100804e+00, -3.31692615e+00],\n",
       "       [-1.04125594e+01, -3.50140251e+00],\n",
       "       [-8.55209377e+00, -3.15841000e+00],\n",
       "       [-7.90673749e-01,  5.15690151e+00],\n",
       "       [-1.00754365e-01,  4.51589257e+00],\n",
       "       [-1.30901393e+00,  3.09420646e+00],\n",
       "       [-9.54755699e+00, -2.18801345e+00],\n",
       "       [-5.32030011e+00, -2.99303869e+00],\n",
       "       [-9.48229870e+00, -5.06821960e+00],\n",
       "       [-6.74361627e+00, -8.87844303e+00],\n",
       "       [-1.02518924e+01, -2.55350460e+00],\n",
       "       [-1.96576392e+00,  5.23446451e+00],\n",
       "       [-5.88036774e+00, -2.36326290e+00],\n",
       "       [-7.34774574e+00, -8.41955499e+00],\n",
       "       [-7.58703957e-01,  3.72276201e+00],\n",
       "       [-8.41357863e+00, -6.85069257e+00],\n",
       "       [-8.20576492e-01,  5.33759195e+00],\n",
       "       [-7.93489041e+00, -7.78403764e+00],\n",
       "       [-5.69446566e+00, -4.06205304e+00],\n",
       "       [-8.57698874e-01,  4.45305717e+00],\n",
       "       [ 1.50975008e-01,  3.10076295e+00],\n",
       "       [-6.55394441e+00, -6.44256627e+00],\n",
       "       [-1.09316272e+01, -4.48636887e+00],\n",
       "       [-6.50155596e+00, -4.65329331e+00],\n",
       "       [-6.93650519e+00, -6.39281292e+00],\n",
       "       [-1.01336898e+01, -4.75061833e+00],\n",
       "       [-9.89148978e+00, -5.47902886e+00],\n",
       "       [-8.89871617e+00, -4.85498304e+00],\n",
       "       [-8.11394993e+00, -7.83656921e+00],\n",
       "       [-5.29078354e+00, -3.64846688e+00],\n",
       "       [-1.41076074e+00,  4.10984872e+00],\n",
       "       [-9.50537595e+00, -4.63402669e+00],\n",
       "       [-7.82749456e+00, -2.51032104e+00],\n",
       "       [-6.38088086e+00, -8.50663809e+00],\n",
       "       [-8.96014913e+00, -8.06349899e+00],\n",
       "       [-7.66603898e+00, -7.59715459e+00],\n",
       "       [-6.46534407e+00, -2.85544633e+00]])"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import silhouette_score \n",
    "from sklearn.metrics import silhouette_samples \n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "light-depression",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 2, 1, 2, 1, 2, 2, 2, 2, 0, 0, 2, 1, 2, 0, 2, 0, 1, 2, 2, 2,\n",
       "       2, 1, 2, 2, 1, 1, 2, 2, 0, 1, 2, 0, 2, 0, 2, 2, 0, 2, 2, 2, 1, 2,\n",
       "       2, 0, 2, 2, 1, 1, 1, 2, 2, 2, 0, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 2,\n",
       "       0, 2, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1,\n",
       "       2, 2, 1, 0, 2, 2, 1, 0, 0, 2, 0, 1, 1, 0, 1, 2, 1, 2, 2, 1, 1, 2,\n",
       "       2, 0, 1, 2, 1, 2, 1, 2, 1, 2, 2, 0, 0, 2, 2, 2, 1, 0, 0, 2, 1, 2,\n",
       "       2, 2, 2, 0, 1, 2, 1, 1, 2, 0, 2, 1, 1, 1, 2, 2, 0, 0, 2, 2, 1, 0,\n",
       "       1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 2, 1, 0, 2, 2, 0, 1, 2,\n",
       "       2, 2, 2, 0, 2, 2, 1, 0, 0, 2, 2, 0, 0, 2, 1, 1, 0, 0, 2, 1, 2, 0,\n",
       "       0, 1, 0, 2, 1, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 1, 2, 1,\n",
       "       2, 0, 2, 2, 2, 2, 2, 1, 2, 1, 0, 2, 0, 2, 1, 1, 2, 0, 1, 0, 2, 2,\n",
       "       0, 0, 0, 0, 2, 2, 0, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2,\n",
       "       1, 2, 0, 0, 2, 2, 2, 2, 1, 1, 2, 1, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1,\n",
       "       1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 0, 0, 2, 2, 2, 0, 2, 0, 0, 2, 0,\n",
       "       0, 2, 1, 0, 2, 2, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 2, 1, 2, 2, 0,\n",
       "       0, 1, 2, 0, 2, 1, 1, 2, 2, 2, 0, 2, 1, 1, 2, 1, 1, 1, 1, 0, 0, 2,\n",
       "       1, 2, 2, 0, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 0, 1, 0, 0, 0, 0, 0,\n",
       "       0, 2, 0, 1, 0, 1, 1, 2, 1, 2, 2, 2, 0, 1, 2, 1, 2, 0, 2, 2, 0, 2,\n",
       "       2, 1, 1, 0, 2, 2, 1, 2, 2, 0, 0, 2, 0, 2, 2, 0, 2, 0, 2, 1, 0, 1,\n",
       "       2, 2, 1, 2, 2, 1, 0, 2, 1, 1, 2, 2, 2, 2, 0, 1, 0, 2, 1, 0, 0, 0,\n",
       "       2, 1, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 1, 2,\n",
       "       1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 0, 2, 1, 2, 0, 1, 0, 1, 0, 2, 1, 1,\n",
       "       0, 2, 2, 0, 2, 2, 2, 0, 2, 1, 2, 2, 0, 0, 0, 2])"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "decimal-african",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.62982017,  0.5034877 ,  0.56148795,  0.84881844,  0.56034142,\n",
       "        0.78740319,  0.39254042,  0.4424015 ,  0.48582704,  0.41586457,\n",
       "        0.62497924,  0.75540751,  0.50080674,  0.8452256 ,  0.54730432,\n",
       "        0.60232423,  0.54574988,  0.68789747,  0.86605921,  0.25389678,\n",
       "        0.49316173,  0.47993065,  0.2222642 ,  0.8096265 ,  0.54091189,\n",
       "        0.30638567,  0.88557311,  0.84050532,  0.52855895,  0.49260117,\n",
       "        0.65291019,  0.85602282,  0.47734375,  0.60418857,  0.44210292,\n",
       "        0.6835351 ,  0.44776257,  0.423086  ,  0.6350923 ,  0.4060121 ,\n",
       "        0.54540657,  0.5628461 ,  0.78366733,  0.37063114,  0.35132112,\n",
       "        0.74493029,  0.53691616,  0.36724842,  0.87717083,  0.79594363,\n",
       "        0.84641859,  0.38341344,  0.42043012,  0.4024608 ,  0.64639537,\n",
       "        0.46244151,  0.31853572,  0.10047008,  0.37909034,  0.56424494,\n",
       "        0.86153448,  0.82630007,  0.53288582,  0.35699772,  0.86994617,\n",
       "        0.52259763,  0.71296285,  0.5269434 ,  0.42375504,  0.3173951 ,\n",
       "        0.67512993,  0.47574584,  0.44493897,  0.70152025,  0.37911024,\n",
       "        0.44338293,  0.75528756,  0.23339973,  0.48832955,  0.36920643,\n",
       "        0.84872127,  0.87346766,  0.53069113,  0.85553096,  0.85764386,\n",
       "        0.47306874,  0.02036611,  0.83126042,  0.38759022,  0.49233068,\n",
       "        0.74566044,  0.60466216,  0.56741342,  0.43416703,  0.83602352,\n",
       "        0.72477786,  0.65632253,  0.53058775,  0.60023269,  0.77641023,\n",
       "        0.84703763,  0.70993659,  0.7801523 ,  0.46161604,  0.84373446,\n",
       "        0.39295281,  0.46052385,  0.88273449,  0.87440032,  0.48304623,\n",
       "        0.53380475,  0.75891465,  0.85876382,  0.38558097,  0.85795763,\n",
       "        0.39785899,  0.85219954,  0.53642823,  0.86038619,  0.43699704,\n",
       "        0.38829633,  0.54291415,  0.69030671,  0.43887074,  0.51384962,\n",
       "        0.51912781,  0.83667847,  0.76248539,  0.69612144,  0.51530997,\n",
       "        0.86167552,  0.55346107,  0.56205672,  0.49273512,  0.38805592,\n",
       "        0.57038854,  0.68677314,  0.20332654,  0.75659329,  0.82280178,\n",
       "        0.51078711,  0.56655943,  0.39855324,  0.87777997,  0.81846156,\n",
       "        0.85011915,  0.53745726,  0.48476499,  0.57083761,  0.62520973,\n",
       "        0.48791422,  0.57163867,  0.80710385,  0.75753237,  0.80107683,\n",
       "        0.50370862,  0.49411065,  0.56270422,  0.46054445,  0.46870708,\n",
       "        0.53443711,  0.52806612,  0.54696216,  0.38036632,  0.8439417 ,\n",
       "        0.43517732,  0.74914748,  0.64728736,  0.41663216,  0.8823285 ,\n",
       "        0.65599758,  0.56449485,  0.51988053,  0.62928512,  0.88015404,\n",
       "        0.56872777,  0.39189978,  0.49345531,  0.46686063,  0.59723997,\n",
       "        0.44721036,  0.30721342,  0.75113026,  0.50932716,  0.73578982,\n",
       "       -0.11420488,  0.41858652,  0.75882296,  0.7275962 , -0.04073665,\n",
       "        0.80153593,  0.87004395,  0.68206941,  0.43331808,  0.46482802,\n",
       "        0.84659276,  0.50866477,  0.68601103,  0.74449975,  0.83022338,\n",
       "        0.73707965,  0.27681202,  0.66098479,  0.28977719,  0.51863521,\n",
       "        0.63445046,  0.40559979,  0.14818081,  0.76068525,  0.23252498,\n",
       "        0.53021521,  0.47737535,  0.20930573,  0.73655361,  0.40050939,\n",
       "        0.38201296,  0.53131423,  0.8300432 ,  0.57416668,  0.83002234,\n",
       "        0.43809863,  0.72601129,  0.30355831,  0.36933954,  0.48245049,\n",
       "        0.50126688,  0.50360422,  0.87011861,  0.56950365,  0.83076761,\n",
       "        0.71764725,  0.53645163,  0.7001754 ,  0.50522187,  0.87888555,\n",
       "        0.77936165,  0.10535855,  0.73083257,  0.87808798,  0.66433392,\n",
       "        0.46478475,  0.37703473,  0.73374533,  0.74890043,  0.73918627,\n",
       "        0.63932594,  0.09590229,  0.56398421,  0.65471361,  0.32850826,\n",
       "        0.50686886,  0.82252268,  0.8784639 ,  0.50307722,  0.55480534,\n",
       "        0.87909816,  0.47641098,  0.31311959,  0.52686075,  0.88545307,\n",
       "        0.20448704,  0.80778118,  0.44642434,  0.40574811,  0.88056023,\n",
       "        0.4973487 ,  0.69311101,  0.72625355,  0.48589387,  0.4978385 ,\n",
       "        0.55313636,  0.50253656,  0.87260952,  0.86131163,  0.40383223,\n",
       "        0.86877735,  0.47545049,  0.55504965,  0.88434796,  0.70495153,\n",
       "        0.88081422,  0.73413228,  0.74319485,  0.86247661,  0.68152552,\n",
       "        0.87029291,  0.81761732,  0.55085702,  0.49102505,  0.55389601,\n",
       "        0.124766  ,  0.4404892 ,  0.53977082,  0.57674226,  0.52475521,\n",
       "        0.71693971,  0.59037229,  0.27134864,  0.55075649,  0.5305809 ,\n",
       "        0.45997724,  0.52098416,  0.69242901,  0.42370109,  0.55411474,\n",
       "        0.56138849,  0.53447704,  0.69329183,  0.54368936,  0.32886853,\n",
       "        0.86126399,  0.71469113,  0.49146367,  0.50494774,  0.82158862,\n",
       "        0.86861319,  0.54403438,  0.73940315,  0.81462808,  0.84352203,\n",
       "        0.48207009,  0.7354327 ,  0.78085872,  0.87875202,  0.04033208,\n",
       "        0.50804578,  0.80938918,  0.51061604,  0.38053425,  0.64455589,\n",
       "        0.67957545,  0.87709406,  0.54770971,  0.49617626,  0.06631062,\n",
       "        0.82052164,  0.85247897,  0.4986702 ,  0.41583248,  0.53794955,\n",
       "        0.73049329,  0.28601778,  0.87874615,  0.86432778,  0.53085921,\n",
       "        0.81504707,  0.80902757,  0.73654387,  0.79629133,  0.69825831,\n",
       "        0.71042076,  0.37753505,  0.87392688,  0.36052199,  0.53293388,\n",
       "        0.65652301,  0.8590337 ,  0.37778142,  0.88171647,  0.55744616,\n",
       "        0.72988524,  0.47205379,  0.25321102,  0.36665898,  0.87510459,\n",
       "        0.54567292,  0.4377203 ,  0.69836179,  0.88279947,  0.73712769,\n",
       "        0.7571288 ,  0.64200399,  0.71414246,  0.66105524,  0.64924985,\n",
       "       -0.03393189,  0.67879166,  0.87717775,  0.70483203,  0.81570721,\n",
       "        0.88445546,  0.42536337,  0.84352976,  0.19940384,  0.33446675,\n",
       "       -0.05200008,  0.63729057,  0.86077417,  0.29232998,  0.85936207,\n",
       "        0.01230106,  0.74072871,  0.54572786,  0.4226642 ,  0.75803727,\n",
       "        0.41490286,  0.47701084,  0.81796862,  0.80656788,  0.63246787,\n",
       "        0.43149716,  0.47554846,  0.67481449,  0.29491288,  0.47884262,\n",
       "        0.73531065,  0.74909774,  0.53905722,  0.60853703,  0.41799506,\n",
       "        0.26889856,  0.65941878,  0.57469934,  0.74695893,  0.53566443,\n",
       "        0.87031783,  0.55546256,  0.74959292,  0.52013136,  0.48602131,\n",
       "        0.84252024,  0.5553399 ,  0.32396765,  0.83121787,  0.6507822 ,\n",
       "        0.40589711,  0.81861161,  0.85537229,  0.51500612,  0.46370284,\n",
       "        0.35233694,  0.41423309,  0.66647621,  0.87838551,  0.55564776,\n",
       "        0.52172866,  0.80216634,  0.74626963,  0.70305507,  0.727976  ,\n",
       "        0.4315848 ,  0.71546113, -0.14042082,  0.70475791,  0.54510442,\n",
       "        0.49963818,  0.50497552,  0.5260391 ,  0.7371355 ,  0.39249758,\n",
       "        0.47181954,  0.51361169,  0.4902578 ,  0.42402416,  0.54710266,\n",
       "        0.42517899,  0.54612333,  0.40920498,  0.73864644,  0.5056526 ,\n",
       "        0.87463183,  0.41531738,  0.88324604,  0.4574416 ,  0.50326717,\n",
       "        0.56519891,  0.86397315,  0.84031419,  0.81795975,  0.55956891,\n",
       "        0.43032946,  0.28423933,  0.75002919,  0.53694244,  0.86418082,\n",
       "        0.50509088,  0.75702551,  0.85123063,  0.47073065,  0.85904201,\n",
       "        0.69214588,  0.32746785,  0.87507056,  0.77556871,  0.47820639,\n",
       "        0.37692453,  0.23345891,  0.46482472,  0.36325517,  0.17966353,\n",
       "        0.31925836,  0.67652463,  0.35889712,  0.87965911,  0.3907438 ,\n",
       "        0.5748237 ,  0.74655924,  0.57403918,  0.69733646,  0.52992071])"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#观察一下不同的K下，轮廓系数发生什么变化？ \n",
    "cluster = KMeans(n_clusters=3, random_state=0).fit(X) \n",
    "silhouette_score(X,cluster_.labels_) #计算所有样本的轮廓系数均值。 \n",
    "silhouette_samples(X,cluster.labels_) #计算每个样本的轮廓系数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "liked-metallic",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.lines.Line2D at 0x1d706332518>"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSV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[
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd \n",
    "score=[] \n",
    "#将k值从2变化到20\n",
    "for i in range(2,20): \n",
    "    cluster= KMeans(n_clusters=i, random_state=0).fit(X) \n",
    "    score.append(silhouette_score(X,cluster.labels_)) \n",
    "plt.plot(range(2,20),score) \n",
    "plt.axvline(pd.DataFrame(score).idxmax()[0]+2,ls=':')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "saving-breeding",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(score).idxmax()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "reported-quebec",
   "metadata": {},
   "source": [
    "轮廓系数有很多优点，它在有限空间中取值，使得我们对模型的聚类效果有一个“参考”。    \n",
    "并且，轮廓系数对数据的分布没有假设，因此在很多数据集上都表现良好。    \n",
    "但它在每个簇的分割比较清洗时表现最好。    \n",
    "但轮廓系数也有缺陷，比如基于密度进行的聚类，或通过 DBSCAN 获得的聚类结果，    \n",
    "如果使用轮廓系数来衡量，则会表现出比真实聚类效果更高的分数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "copyrighted-citizen",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cluster_01 = KMeans(n_clusters =8,init='k-means++',max_iter=10).fit(X) \n",
    "cluster_01.n_iter_ # 输出运行的迭代次数 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "indoor-sharp",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.32349786297259425"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "silhouette_score(X,cluster_01.labels_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "artificial-introduction",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cluster_02 = KMeans(n_clusters =8,init='random',max_iter=10).fit(X) \n",
    "cluster_02.n_iter_ # 输出运行的迭代次数 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "charged-control",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.3751511768524732"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "silhouette_score(X,cluster_02.labels_)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "processed-emphasis",
   "metadata": {},
   "source": [
    "init='k-means++'，一般使用默认即可。一般效果差不多"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "intelligent-cooking",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
